package com.yh.ldzl.service.impl;

import com.ruoyi.common.core.web.page.PageDomain;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.core.web.page.TableSupport;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.yh.ldzl.domain.QcTemplate;
import com.yh.ldzl.mapper.QcTemplateMapper;
import com.yh.ldzl.service.QcTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class QcTemplateServiceImpl implements QcTemplateService {

    @Autowired
    private QcTemplateMapper qcTemplateMapper;

    @Override
    public List<QcTemplate> selectQcTemplateList(QcTemplate qcTemplate) {
        PageDomain pageDomain = TableSupport.buildPageRequest();
        Integer pageNum = pageDomain.getPageNum();
        Integer pageSize = pageDomain.getPageSize();
        List<QcTemplate> list= qcTemplateMapper.selectQcTemplateList(qcTemplate);

        return list;
    }

    @Override
    public boolean selectQcTemplateNameUnique(String template_name) {
        return qcTemplateMapper.selectQcTemplateNameUnique(template_name) == 0;
    }

    @Override
    public boolean insertQcTemplate(QcTemplate qcTemplate) {
        qcTemplate.setCreate_by(SecurityUtils.getUsername());
        return qcTemplateMapper.insertQcTemplate(qcTemplate) >0;
    }

    @Override
    public boolean updateQcTemplate(QcTemplate qcTemplate) {
        qcTemplate.setUpdate_by(SecurityUtils.getUsername());
        return qcTemplateMapper.updateQcTemplate(qcTemplate) >0;
    }

    @Override
    public boolean deleteQcTemplate(List<Long> ids) {
        return qcTemplateMapper.deleteQcTemplate(ids) >0;
    }

    @Override
    public List<QcTemplate> selectQcTemplateBasicInformation() {
        PageDomain pageDomain = TableSupport.buildPageRequest();
        Integer pageNum = pageDomain.getPageNum();
        Integer pageSize = pageDomain.getPageSize();
        return qcTemplateMapper.selectQcTemplateBasicInformation();
    }
}